﻿Imports System.Xml

Class Application

    ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
    ' can be handled in this file.

    Private Shared mInstance As Application

    Public Shared ReadOnly Property AppVersion As String
        Get
            Return getInstance.getVersion
        End Get
    End Property

    Public Sub New()
        Debug.WriteLine("Application Class Instantiated")
        mInstance = Me

    End Sub

    Shared Function getInstance() As Application
        Return mInstance
    End Function

    Private Function getVersion() As String
        Dim version As String = "!ERROR!"
        ' Parse the version from the app.manifest XML file
        ' There shoudl be an easier way to get the Publish Verison :-(
        Try
            Dim m_xmld = New XmlDocument()
            m_xmld.Load(Forms.Application.ExecutablePath & ".manifest")
            Dim v = m_xmld.ChildNodes.Item(1).ChildNodes.Item(0).Attributes.GetNamedItem("version").Value
            If v <> "" Then
                version = v
            End If
        Catch ex As Exception
        Finally
        End Try
        Return version
    End Function


    Shared Sub logShared(ByVal msg As String)
        Debug.WriteLine("LOG SHARED: " & msg)
    End Sub

    Public Sub logPublic(ByVal msg As String)
        Debug.WriteLine("LOG PUBLIC: " & msg)
    End Sub
End Class
